home *** CD-ROM | disk | FTP | other *** search
- ##############################################################################
- # standard.mml
- #
- # Standard MailShield subroutines used in a variety of places.
- #
-
- ##############################################################################
- # this is the standard (default) rejection notice.
-
- sub DefaultRejection {
- # log this rejection as type "log_refuse"
-
- # if log level is 1 or more, then log additional info about this refusal.
- if ($loglevel >= 1) {
- $log_entry = "Unwanted email\n";
- $log_entry .= " Reason: ".$log_message."\n";
- $log_entry .= " State: ".$state."\n";
- $log_entry .= " TCP/IP: ".$PeerHostname." [".$PeerTcpip."]\n";
-
- # log different pieces of information, depending on what mail state was reached
- if ($state_number >= 30) {
- $log_entry .= " MAIL FROM: ".$SmtpMailFrom."\n";
- };
- if ($state_number >= 40) {
- $log_entry .= " RCPT TO: ".join(",", @SmtpRcptTo)."\n";
- };
- if ($state_number >= 50) {
- $log_entry .= " Subject: ".&HeaderGet("subject")."\n";
- $log_entry .= " From: ".&HeaderGet("from")."\n";
- $log_entry .= " To: ".&HeaderGet("to")."\n";
- $log_entry .= " Date: ".&HeaderGet("date")."\n";
- };
-
- &LogMessage($log_entry, "log_refuse");
- }
- else {
- &LogMessage("Refusing message because '".$log_message."'", "log_refuse");
- };
-
- # Check to see if this message should be sent to a backup server, a backup account,
- # have the subject marked, or just reject the message.
- # However, if this is a relay rejection, then always reject them, do not defer
- # rejection.
- if ((!$relay_rejection) && ((length($mark_subject) > 0) || (length($backup_mail_server) > 0) || (length($receive_suspicious_email) > 0))) {
- # If the message should not be rejected, but should have some other treatment, first determine
- # if we have received the message yet, or not. If we have not yet received the message, then
- # delay action until the DATA stage.
-
- if ($state eq "DATA") {
- # If we have received the message, then we can treat the message
- &SendMessageToBackup;
- };
-
- # If this message should be rejected, but we have not received the body of message
- # yet, then delay rejection until we have received the message.
- $send_to_backup = TRUE;
- return;
- };
-
- # If a refusal message was defined, then display it to the SMTP host connected to us
- if ($helpful_refuse_message) {
- &Message($log_message);
- }
- else {
- &Message($smtp_message);
- };
-
- # hang up
- &Hangup;
- };
-
- sub SendMessageToBackup {
-
- if (length($mark_subject) > 0) {
- # if we have been told to mark the subject rather than rejecting the message, then do that.
-
- # First, get the current header text from $Header
- &HeaderParse($Header);
- # Then, re-set the Subject
- &HeaderSet("subject", $mark_subject.&HeaderGet("subject"));
- # Finally, commit the changes to the $Header variable
- $Header = &HeaderBuild;
- };
-
- if (length($receive_suspicious_email) > 0) {
- # Redirect rejected mail to a backup email address, if one is defined.
- # Tell the sender that we received the message ok, so that they don't think there's a problem.
- $Header .= "\nX-Originally-To: ".join(", ", @SmtpRcptTo).
- "\nX-Redirected-To: ".$receive_suspicious_email;
- undef @SmtpRcptTo;
- push(@SmtpRcptTo, $receive_suspicious_email);
- };
-
- if (length($backup_mail_server) > 0) {
- # redirect this email message to a backup mail server, if one is defined
- $smtp_server = $backup_mail_server;
- };
-
- $Header .= "\nX-Reason: ".$log_message;
-
- &CommitHeader;
- &Accept;
- };
-
-
- ##############################################################################
- # redirect this message to the administrator.
-
- sub RedirectToAdmin {
-
- # add the original recipient list to the header, then clear the recipient list
- $Header .= "\nX-Originally-To".join(", ", @SmtpRcptTo);
- undef @SmtpRcptTo;
-
- # insert a header to indicate that this message is being forwarded
- $Header .= "\nX-Redirected-To".$receive_suspicious_email;
- &CommitHeaders;
-
- # redefine the recipient list to be the admin email address designated
- # to receive suspicious email.
- push(@SmtpRcptTo, $receive_suspicious_email);
-
- # make a note in the log of this redirecting.
- &LogMessage("Redirecting suspicious email from SMTP host: ".$PeerHostname. " to ".$receive_suspicious_email, "log_refuse");
-
- # accept the message, so as to prevent further processing of it.
- &Accept;
- };
-
-
-